#include<stdio.h>
#include<string.h>
#define tolower(c) (c>='A'&&c<='Z' ? 'a'-'A'+c:c)
#define MAXN 1024+1
int index(char s[], char t[]);

int main()
{
    FILE *IN, *OUT;
    if((IN = fopen("filein.txt","r")) == NULL)
    {
        printf("The file do not exist.\n");
        return -1;
    }
    OUT = fopen("fileout.txt","w");
    char in[255], out[255], line[MAXN], tmp[MAXN];
    scanf("%s\n%s", in, out);
    while(fgets(line, MAXN, IN) != NULL)
    {
        char *p= line;
        int loc = index(line, in);
        while(loc >= 0)
        {
            p += loc;
            strcpy(tmp, p+strlen(in));
            strcpy(p, out);
            strcat(p+strlen(out), tmp);
            loc = index(p, in);
        }
        fputs(line, OUT);
    }
    fclose(IN);
    fclose(OUT);
    return 0;
}

int index(char s[], char t[])
{
    int i, j, k;
    for(i=0;s[i]!='\0';i++)
    {
        for(j=i,k=0;t[k]!='\0' && tolower(s[j])==tolower(t[k]);j++,k++);
        if(t[k] == '\0')
        return i;
    }
    return -1;
}